/*
 * main.cc
 *
 *  Created on: Nov 18, 2010
 *      Author: fify
 */

#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	int m, t, u, f, d;

	int res;
	char ch;

	while(cin >> m >> t >> u >> f >> d)
	{
		res = 0;
		for(int i = 0;i<t;i++)
		{
			cin >> ch;

			switch(ch)
			{
			case 'u':
			case 'd':
				m -= u + d;
				break;
			case 'f':
				m -= f + f;
				break;
			}

			if(m > 0)
				res = i + 1;
		}

		cout << res << endl;
	}
}
